#include <windows.h>
#include <vector>
#include "IGameState.h"
#include "SGD Wrappers/CSGD_Direct3D.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "SGD Wrappers/CSGD_DirectSound.h"
#include "SGD Wrappers/CSGD_WaveManager.h"
#include "SGD Wrappers/CSGD_DirectInput.h"
#include "CBitmapFont.h"
#include "CPlayer.h"
using namespace std;

class CMessage;
class MailSystem;

enum eFactions{MECHANOSWARM, SPIRITUK, ALLU};

class CGame
{
	////////////////////////////////////////////////////////////////////////////////////////
	//	For game timing:
	DWORD								m_dwTimeStamp;
	float								m_fElapsedTime;		//	How much time has passed between frames
	//																in seconds.
	DWORD								m_dwPreviousTime;	//	Holds the time stamp from last frame.
	float								m_fGameTime;		//	Holds the amount of time the game
	//																has been running.
	////////////////////////////////////////////////////////////////////////////////////////
	//	For FPS counting:
	int									m_nFrameCount;		//	Holds the current frame count
	int									m_nFPS;				//	Holds the last frame's frame count for display
	DWORD								m_dwFrameTimeStamp;	//	Holds the time stamp from the last time
	//																we calculated FPS.
	////////////////////////////////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////////////////////////////////
	//	For window toggle:
	int									m_nScreenWidth;
	int									m_nScreenHeight;
	bool								m_bIsWindowed;
	//
	////////////////////////////////////////////////////////////////////////////////////////

	/////////////////////
	//	Put this in Hero
	int m_nFaction;
	//
	////////////////////
	CBitmapFont m_bfItem;
	int m_nNumEnemy;
	int m_nChoiceSound;
	int m_nChosenSound;
	bool m_bIsPaused;
	RECT m_rectCamera;
	vector<IGameState*> m_vecState;
	float m_nMusicVol;
	float m_nSFXVol;
	int m_nRatDeath;
	int m_nChildDeath;

	void Render();
	////////////////////////////////////////////////////////////////////////////////////////
	//	Proper singleton:
	//	Constructor
	CGame();
	//	Trilogy of Evil:
	//		Copy constructor
	CGame(const CGame&);
	//		Assignment Operator
	CGame& operator=(const CGame&);
	//		Destructor
	~CGame();
	//
	////////////////////////////////////////////////////////////////////////////////////////
public:


	//Accessors
	vector<IGameState*> VecState() const { return m_vecState; }
	RECT RectCamera() const { return m_rectCamera; }
	void RectCamera(RECT val) { m_rectCamera = val; }
	int GetScreenWidth() {return m_nScreenWidth;};
	int GetScreenHeight() {return m_nScreenHeight;};
	int GetNumEnemy() { return m_nNumEnemy; };
	int GetFaction() const { return m_nFaction; }
	int ChoiceSound() const { return m_nChoiceSound; }
	int ChosenSound() const { return m_nChosenSound; }
	bool IsPaused() const { return m_bIsPaused; }
	void IsPaused(bool val) { m_bIsPaused = val; }
	float MusicVol() const { return m_nMusicVol; }
	void MusicVol(float val) { m_nMusicVol = val; }
	bool IsWindowed() const { return m_bIsWindowed; }
	void IsWindowed(bool val) { m_bIsWindowed = val; }
	float SFXVol() const { return m_nSFXVol; }
	void SFXVol(float val) { m_nSFXVol = val; }

	void SetFaction(int nFaction) { m_nFaction = nFaction; }
	void SetNumEnemy( int nNumEnemy ) { m_nNumEnemy = nNumEnemy; };

	static CGame* GetInstance();
	void Init(HWND hwnd, HINSTANCE hInstance, int nScreenWidth, int nScreenHeight, bool bIsWindowed);
	bool Main();
	void Shutdown();
	void PopState();
	void PushState(IGameState* state);
	void ClearAllStates();
	void ChangeState(IGameState *state);
	static void MessageProc(CMessage* message);
};